package com.javashow.main.info.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.javashow.main.info.dao.IMainInfoDao;
import com.javashow.pojo.GridColumn;

@SuppressWarnings("unchecked")
@Repository(value = "mainInfoDao")
public class MainInfoDaoImpl implements IMainInfoDao {
	
	@Resource
	private SessionFactory sessionFactory;

	@Override
	public List<GridColumn> queryColumnsByCode(String code) {
		List<GridColumn> result = new ArrayList<GridColumn>();
		
		Query query = sessionFactory.getCurrentSession().createQuery("from GridColumn gc where gc.code=?");
		query.setParameter(0, code);
		
		result = query.list();
	
		return result;
	}
	
	public List queryDeptInfo() {
		List result = new ArrayList();
		String sql = "select id,code,manager_code,dept_name,description from department";
		
		Query query = sessionFactory.getCurrentSession().createSQLQuery(sql);
		
		result = query.list();
		
		return result;
	}

	@Override
	public List queryStoreNameByCode(String code) {
		List result = new ArrayList();
		
		String sql = "select id, code, name from comm_grid_store where code='" + code + "'";
		
		Query query = sessionFactory.getCurrentSession().createSQLQuery(sql);
		
		result = query.list();
		
		return result;
	}
}

















